package com.fileStorageService.service.impl;

import com.fileStorageService.bean.BaseCon;
import com.fileStorageService.service.DownFileService;
import com.projectCommon.util.commonUtil.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.File;
import java.net.URL;

@Service
@Slf4j
public class DownFileServiceImpl implements DownFileService {
    @Autowired
    private BaseCon baseCon;

    @Override
    public File downloadFile(String fileName) {
        File resourceFile = FileUtil.getResourceFile(baseCon.getSmokePicPath() + "/" + fileName);
        return resourceFile;
//        String path = FileUtil.class.getClassLoader().getResource(resourceFileName).getPath();
//        File file = new File(path);
//        return file;
//        URL resource = DownFileServiceImpl.class.getClassLoader().getResource(baseCon.getSmokePicPath() + "\\" + fileName);
//        String file = resource.getFile();
//        String path = resource.getPath();
//        return new File(path);
    }
}
